package insight.sm.controllers;

import java.io.BufferedReader;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.json.JSONException;
import org.json.JSONObject;

public class GenericController {
	public static JSONObject readJSON(HttpServletRequest request) throws IOException {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = request.getReader();
        String str;
        while ((str = br.readLine()) != null) {
                sb.append(str);
        }
        try {
                JSONObject jObj = new JSONObject(sb.toString());
                return jObj;
        } catch (JSONException e) {
                e.printStackTrace();
                return null;
        }
}
}
